﻿<ResourceDictionary 
    x:Class="ProjectSetupTemplates.xaml"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:DataObjects="clr-namespace:TfsWorkbench.ProjectSetupUI.DataObjects"
    xmlns:UIElements="clr-namespace:TfsWorkbench.UIElements;assembly=TfsWorkbench.UIElements"
    xmlns:ProjectSetupUI="clr-namespace:TfsWorkbench.ProjectSetupUI"
    xmlns:Helpers="clr-namespace:TfsWorkbench.ProjectSetupUI.Helpers"
    >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/TfsWorkbench.UIElements;Component/Resources/ApplicationStyles.xaml"/>
        <ResourceDictionary Source="/TfsWorkbench.UIElements;Component/Resources/CommandButtonStyles.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="ListViewItem">
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
    </Style>

    <DataTemplate x:Key="WorkStreamListItem" DataType="{x:Type DataObjects:WorkStream}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            
            <TextBlock Text="{Binding Name}" />
            <TextBlock Grid.Column="1">
                <Run xml:space="preserve" Text=" - " />
                <TextBlock Text="{Binding Cadance}" />
                <Run xml:space="preserve" Text=" days" />
            </TextBlock>
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="PathNodeTemplate" DataType="{x:Type DataObjects:ProjectNodeVisual}">
        <Border 
            Width="125" 
            Height="75" 
            BorderBrush="Black" 
            BorderThickness="1" 
            Background="AliceBlue"
            ToolTip="{Binding Path}"
            Cursor="{x:Static UIElements:CustomCursors.Hand}"
            Name="TopBorder"
            >
            <Border.ContextMenu>
                <ContextMenu>
                    <MenuItem
                        Command="{x:Static Helpers:LocalCommandLibrary.NewAssociatedItemCommand}"
                        CommandParameter="{Binding}"
                        CommandTarget="{Binding Path=PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}"
				        >
				        <MenuItem.Icon>
							<ContentControl Template="{StaticResource AddIconTemplate}" Style="{StaticResource MenuIconStyle}" />
						</MenuItem.Icon>
					</MenuItem>
                    <MenuItem
                        Header="Edit Associated Item"
                        Command="{x:Static UIElements:CommandLibrary.EditItemCommand}"
                        CommandParameter="{Binding WorkbenchItem}"
                        CommandTarget="{Binding Path=PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}"
				        >
				        <MenuItem.Icon>
							<ContentControl Template="{StaticResource EditIconTemplate}" Style="{StaticResource MenuIconStyle}" />
						</MenuItem.Icon>
					</MenuItem>
                    <MenuItem
                        Command="{x:Static Helpers:LocalCommandLibrary.FilterOnNodeCommand}"
                        CommandParameter="{Binding}"
                        CommandTarget="{Binding Path=PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}"
				        >
				        <MenuItem.Icon>
							<ContentControl Template="{StaticResource FilterIconTemplate}" Style="{StaticResource MenuIconStyle}" />
						</MenuItem.Icon>
					</MenuItem>
                    <MenuItem
                        Command="{x:Static Helpers:LocalCommandLibrary.AddChildNodeCommand}"
                        CommandParameter="{Binding}"
                        CommandTarget="{Binding Path=PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}"
						>
				        <MenuItem.Icon>
							<ContentControl Template="{StaticResource AddIconTemplate}" Style="{StaticResource MenuIconStyle}" />
						</MenuItem.Icon>
					</MenuItem>
                    <MenuItem
                        Command="{x:Static Helpers:LocalCommandLibrary.RenameNodeCommand}"
                        CommandParameter="{Binding}"
                        CommandTarget="{Binding Path=PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}"
						>
				        <MenuItem.Icon>
							<ContentControl Template="{StaticResource EditIconTemplate}" Style="{StaticResource MenuIconStyle}" />
						</MenuItem.Icon>
					</MenuItem>
                    <MenuItem
                        Command="{x:Static Helpers:LocalCommandLibrary.DeleteNodeCommand}"
                        CommandParameter="{Binding}"
                        CommandTarget="{Binding Path=PlacementTarget, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ContextMenu}}}"
						>
				        <MenuItem.Icon>
							<ContentControl Template="{StaticResource DeleteIconTemplate}" Style="{StaticResource MenuIconStyle}" />
						</MenuItem.Icon>
					</MenuItem>
                </ContextMenu>
            </Border.ContextMenu>
            <Grid>
                <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Binding Name}" />
                <Button 
                    HorizontalAlignment="Right" 
                    VerticalAlignment="Top" 
                    CommandParameter="{Binding WorkbenchItem}" 
                    Command="{x:Static UIElements:CommandLibrary.EditItemCommand}" 
                    >
                    <Button.ToolTip>
                        <UIElements:WorkbenchItemToolTip WorkbenchItem="{Binding WorkbenchItem}" />
                    </Button.ToolTip>
                    <Button.Style>
                        <Style TargetType="Button" BasedOn="{StaticResource EditButtonStyle}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding WorkbenchItem}" Value="{x:Null}">
                                    <Setter Property="Visibility" Value="Hidden" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                </Button>
            </Grid>
        </Border>
    </DataTemplate>

    <Style x:Key="NodePointEllipse" TargetType="Ellipse">
        <Setter Property="Fill" Value="Black" />
        <Setter Property="Width" Value="6" />
        <Setter Property="Height" Value="6" />
        <Setter Property="Margin" Value="-3, -3, 0, 0" />
    </Style>

    <Style x:Key="NodeLinkLine" TargetType="Line">
        <Setter Property="Stroke" Value="Black" />
        <Setter Property="StrokeThickness" Value="1" />
    </Style>

    <Style x:Key="DeleteCommandButton" BasedOn="{StaticResource DeleteButtonStyle}" TargetType="{x:Type Button}">
		<Setter Property="ToolTip" Value="Delete" />
    </Style>
    
    <DataTemplate x:Key="ReleaseCollectionTemplate"  DataType="{x:Type DataObjects:ReleaseCollection}">
        <ListView ItemsSource="{Binding}" VerticalContentAlignment="Center">
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn Header="Release Name">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:Release}">
                                    <TextBox MinWidth="150" Text="{Binding Path=Name}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Start Date">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:Release}">
                                    <DatePicker SelectedDate="{Binding StartDate}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="End Date">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:Release}">
                                    <DatePicker SelectedDate="{Binding EndDate}" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:Release}">
                                    <Button 
                                        Style="{StaticResource DeleteCommandButton}" 
                                        Command="{x:Static Helpers:LocalCommandLibrary.DeleteNamedItemCommand}"
                                        CommandParameter="{Binding}"
                                        />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
    </DataTemplate>

    <DataTemplate x:Key="WorkStreamCollectionTemplate"  DataType="{x:Type DataObjects:WorkStreamCollection}">
        <ListView DockPanel.Dock="Top" ItemsSource="{Binding}">
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn Header="Work Stream Name">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:WorkStream}">
                                    <TextBox Text="{Binding Name}" MinWidth="150" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Cadance">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:WorkStream}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <TextBox Text="{Binding Cadance}" MinWidth="50" />
                                        <TextBlock Grid.Column="1" Margin="2,0,0,0" VerticalAlignment="Center">Days</TextBlock>
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:WorkStream}">
                                    <Button 
                                        Style="{StaticResource DeleteCommandButton}" 
                                        Command="{x:Static Helpers:LocalCommandLibrary.DeleteNamedItemCommand}"
                                        CommandParameter="{Binding}"
                                        />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
    </DataTemplate>

    <DataTemplate x:Key="TeamCollectionTemplateWithWorkStreams" DataType="{x:Type DataObjects:TeamCollection}">
        <ListView DockPanel.Dock="Top" ItemsSource="{Binding}">
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn Header="Team Name">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:Team}">
                                    <TextBox Text="{Binding Name}" MinWidth="150" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Capacity">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:Team}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <TextBox Text="{Binding Capacity}" MinWidth="50" />
                                        <TextBlock Grid.Column="1" Margin="2,0,0,0" VerticalAlignment="Center">Hours</TextBlock>
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Sprint Length">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:Team}">
                                    <ComboBox 
                                        MinWidth="175"
                                        SelectedItem="{Binding WorkStream}" 
                                        ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=ProjectSetupUI:SetupDialogBase}, Path=ProjectSetup.WorkStreams}" 
                                        ItemTemplate="{StaticResource WorkStreamListItem}"
                                        />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn>
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:Team}">
                                    <Button 
                                        Style="{StaticResource DeleteCommandButton}" 
                                        Command="{x:Static Helpers:LocalCommandLibrary.DeleteNamedItemCommand}"
                                        CommandParameter="{Binding}"
                                        />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
    </DataTemplate>

    <DataTemplate x:Key="TeamCollectionTemplate" DataType="{x:Type DataObjects:TeamCollection}">
        <ListView DockPanel.Dock="Top" ItemsSource="{Binding}">
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn Header="Team Name">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:Team}">
                                    <TextBox Text="{Binding Name}" MinWidth="150" />
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Capacity">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:Team}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <TextBox Text="{Binding Capacity}" MinWidth="50" />
                                        <TextBlock Grid.Column="1" Margin="2,0,0,0" VerticalAlignment="Center">Hours</TextBlock>
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                        <GridViewColumn Header="Sprint Length">
                            <GridViewColumn.CellTemplate>
                                <DataTemplate DataType="{x:Type DataObjects:Team}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <TextBox Text="{Binding WorkStream.Cadance}" />
                                        <TextBlock
                                            Grid.Column="1"
                                            VerticalAlignment="Center"
                                            Margin="2,0,0,0"
                                            Text="Days" 
                                            />
                                    </Grid>
                                </DataTemplate>
                            </GridViewColumn.CellTemplate>
                        </GridViewColumn>
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
    </DataTemplate>
</ResourceDictionary>